package com.xiaotu.spider.douban.pipeline;

import java.util.List;

import org.springframework.stereotype.Component;

import com.xiaotu.common.model.ShortCommentsModel;
import com.xiaotu.common.model.TVNotBroadcastModel;
import com.xiaotu.common.util.Constants;
import com.xiaotu.common.util.DataRedisKeyUtils;
import com.xiaotu.spider.APipeline;

import us.codecraft.webmagic.ResultItems;
import us.codecraft.webmagic.Task;
@Component("DouBanTVNotBrdPipeline")
public class DouBanTVNotBrdPipeline extends APipeline{

	@Override
	protected void doProcess(ResultItems resultItems, Task task) {
		List<TVNotBroadcastModel> tv_doubanList = resultItems.get(TVNotBroadcastModel.class.getName());
        if (tv_doubanList == null || tv_doubanList.size()==0)
            return;
        String key = DataRedisKeyUtils.getKey(Constants.DataRedisKey.TV_NOT_DOUBAN_YYYYMMDD);
    	
        for (TVNotBroadcastModel tv_douban : tv_doubanList) {
        	cacheHandler.hSet(key, tv_douban.getTvname()+"_"+tv_douban.getTimestamp()+"", tv_douban);
            cacheHandler.setCacheTimeout(key);
		}
        
	}
	
}
